<?php echo $this->element('displayHeader'); ?>
<div class="toolbar"><?php
echo $this->element('toolbar', array('buttons' => array(
        'add', 'search', 'refresh', 'import',
        array('print' => array('action' => 'print_display', 'params' => '')),
        array('excel' => array('model' => 'CustProductSite', 'action' => 'excel_display', 'params' => ''))
        )));
?>
</div>

<?php if (empty($this->data)) : // ถ้าไม่มีข้อมูล ?>
<?php echo $this->element('dataNotFound'); ?>
<? else : // ถ้ามีข้อมูล ?>
<?php $paginator->options(array('update' => 'content', 'indicator' => 'indicator')); ?>
<?php echo $this->element('dataCaptionLimit'); ?>
<?php $cur = $paginator->counter(array('format' => '%start%')); ?>
        <table class="data">
            <thead>
                <tr>
                    <th class="no"><?php echo $paginator->sort('No', 'Product.id'); ?></th>
                    <th width="130px"><?php echo $paginator->sort('Part no', 'Product.part_no'); ?></th>
                    <th><?php echo $paginator->sort('Category', 'Category.id'); ?></th>
                    <th><?php echo $paginator->sort('Brand', 'Brand.name'); ?></th>
                    <th><?php echo $paginator->sort('Title', 'Product.title'); ?></th>
                    <th><?php echo $paginator->sort('Model', 'Product.model'); ?></th>
                    <th width="100px"><?php echo $paginator->sort('Current Stock', 'Product.current_stock'); ?></th>
                    <th width="80px">Amount</th>
                    <th width="48px">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
        <?php foreach ($this->data as $key => $data): ?>
        <?php
            $tableCell = array();
            $tableCell[] = $cur++;
            $tableCell[] = $data['Product']['part_no'];
            $tableCell[] = $data['Category']['name'];
            $tableCell[] = $data['Brand']['name'];
            $tableCell[] = $html->tag('span', $data['Product']['title'], array('id' => "ProductTitle$cur"));
            $tableCell[] = $html->tag('span', $data['Product']['model'], array('id' => "ProductModel$cur"));
            $tableCell[] = $html->tag('span', number_format($data['Product']['current_stock']), array('id' => "currentStock$cur", 'class' => 'right'));
            $tableCell[] = $html->tag('div', number_format($data['Product']['current_stock'] * $data['Product']['price']), array('class' => 'right'));
            $tableCell[] = $ajax->link($html->image('icon/edit.png', array('title' => 'edit', 'alt' => 'edit')), 'view/' . $data['Product']['id'],
                            array('indicator' => 'indicator', 'update' => 'content'), null, false) . '&nbsp;' .
                    $ajax->link($html->image('icon/popup.png', array('title' => 'Index information')),
                            array('controller' => 'products_serials', 'action' => 'popup_view', $data['Product']['id']),
                            array('update' => 'content', 'position' => 'bottom', 'indicator' => 'indicator'), null, false);
            echo $html->tableCells($tableCell, array('class' => 'odd-cell'), array('class' => 'even-cell'));
        ?>
        <?php endforeach; ?>
        </tbody>
    </table>
<?php echo $this->element('paging'); ?>
<? endif; ?>
